	function writeCondition(text){
		var tc = Ext.getDom("selColumnCondition_simple_conditions_");
	    var tclen = tc.value.length;
	    tc.focus();
	    if(typeof document.selection != "undefined")
	    {
	        document.selection.createRange().text = text;  
	    }
	    else
	    {
	        tc.setValue(tc.value.substr(0,tc.selectionStart)+text+tc.value.substring(tc.selectionStart,tclen));
	    }
	}
	function addquery(o,sqlTextareaId,column)
	{
	    var tc = Ext.getDom(sqlTextareaId);
	    var tclen = tc.value.length;
	    tc.focus();
	    var str=o.text;
	    if(column)
	    	str+="("+column+")";
	    if(typeof document.selection != "undefined")
	    {
	        document.selection.createRange().text = str;  
	    }
	    else
	    {
	        tc.setValue(tc.value.substr(0,tc.selectionStart)+str+tc.value.substring(tc.selectionStart,tclen));
	    }
	}
	
	//收集宾栏 by mengqingyu
	function findMeasureList(){
		var H = '';
		var comboboxArray = new Array();//修改指标下拉框数据
		columns=[];
		//循环宾栏
		jQuery("#myListH > li").each(function (index, domElement) {
			flag=true;
			columns.push(jQuery(this).attr('label'));
			columnsText = columnsText + jQuery(this).attr('label') + ',';
			var temp='';
			var label='';
			if(jQuery(this).attr('customH')=='true'){
				temp = jQuery(this).attr('column')+ '@' + jQuery(this).attr('time');
				label = jQuery(this).attr('label');
			}else{
				if(jQuery(this).attr('d') == 'v'){
					temp = '$' + jQuery(this).attr('table')+"."+jQuery(this).attr('column')+ '@[dimension]' + jQuery(this).attr('time');
				}else{
					temp = '$' + jQuery(this).attr('table')+"."+jQuery(this).attr('column')+ '@' + jQuery(this).attr('time');
					label = jQuery(this).attr('label');
				}
			}
			var array = new Array();
			array.push(label);
			array.push(temp);
			comboboxArray.push(array);
			H = H + temp +';';
		});
		backupParam.data = comboboxArray;
		backupParam.H = H;
	}
	
	//修改指标 by mengqingyu
	function updateMeasure()
	{
		var grid1 = Ext.getCmp('grid');
		//取到查询条件
		var conditions='';
		if(Ext.getCmp('conditions_grid_') != null){
			Ext.getCmp('conditions_grid_').getStore().each(function(record){
				conditions += ' ' + record.data.join + ' ' + record.data.code;
			});
		}
		//刷新表格
		grid1.baseParams.globleConditions=conditions;
		grid1.baseParams.collist=backupParam.H;
		grid1.baseParams.columnListStr=Ext.getCmp('comboBoxMeasureId').getValue()+";"+backupParam.measureValue;
		grid1.baseParams.method="updateMeasure";
		grid1.baseParams.xmlId=xml_id_;
		grid1.baseParams.name=backupParam.tableLabel;
		grid1.baseParams.column = backupParam.column;
		grid1.baseParams.label = backupParam.label;
		grid1.baseParams.orderbys ="";
		grid1.baseParams.currentTime=jQuery("#currentTime").val();
		grid1.baseParams.currentTimeWeiBiao = jQuery("#currentTimeWeiBiao").val();
		grid1.baseParams.kaohekoujing = Ext.getCmp('kaohekoujing').getValue();
		grid1.parseHeader=true; //自定义报表需要每次重新解析表头
		grid1.load();
		if(colFlag==true)   //去掉复杂表头
			grid.reconfigure(grid1.ds, new Ext.grid.ColumnModel({defaults:{align:'center'},rows:[],columns:grid1.ds.head}));
		document.getElementById("presave").disabled = false;
	}